package com.jn.algorithm.day002.question7;

import java.util.Stack;

/**
 * @author 江南大学1033190417
 * @date 2022/4/16 23:35
 */
public class Solution {
    public int reverse(int x) {
        Character fuhao = null;//符号标记
        Stack<Character> stack=new Stack<>();
        String s = String.valueOf(x);
        for (int i = 0; i < s.length(); i++) {
            if (s.charAt(i)=='-'||s.charAt(i)=='+'){
                fuhao=s.charAt(i);
            }else {
                stack.add(s.charAt(i));
            }
        }
        if (fuhao!=null)
            stack.add(fuhao);
        StringBuilder res=new StringBuilder();
        while (!stack.isEmpty()){
            Character pop = stack.pop();
            res.append(pop);
        }
        try {
            return Integer.parseInt(res.toString());
        }catch (Exception e){
            return 0;
        }
    }

    public int reverse2(int x) {



        return 0;
    }

    public static void main(String[] args) {
        Solution solution=new Solution();
        System.out.println(solution.reverse(1534236469));
    }
}
